package com.medeolinx.model.data;

// Generated May 1, 2012 12:20:21 AM by Hibernate Tools 3.4.0.CR1

import static javax.persistence.GenerationType.IDENTITY;

import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.hibernate.annotations.Cascade;
import org.hibernate.annotations.CascadeType;
import org.hibernate.annotations.OrderBy;

/**
 * Terrain generated by hbm2java
 */
@Entity
@Table(name = "terrain", catalog = "medeo12_terrain")
public class Terrain implements java.io.Serializable {
	private static final long serialVersionUID = -1485278881813218051L;

	private Integer id;
	private Album album;
	private String name;
	private String description;
	private List<Comment> comments = new LinkedList<Comment>();
	private Set<Annotation> annotations = new HashSet<Annotation>(0);
	private Set<GeneData> geneDatas = new HashSet<GeneData>(0);

	public Terrain() {
	}

	public Terrain(Album album, String name) {
		this.album = album;
		this.name = name;
	}

	public Terrain(Album album, String name, String description, List<Comment> comments, Set<Annotation> annotations, Set<GeneData> geneDatas) {
		this.album = album;
		this.name = name;
		this.description = description;
		this.comments = comments;
		this.annotations = annotations;
		this.geneDatas = geneDatas;
	}

	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "id", unique = true, nullable = false)
	public Integer getId() {
		return this.id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "album_id", nullable = false)
	public Album getAlbum() {
		return this.album;
	}

	public void setAlbum(Album album) {
		this.album = album;
	}

	@Column(name = "name", nullable = false, length = 45)
	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@Column(name = "description")
	public String getDescription() {
		return this.description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	@OneToMany(fetch = FetchType.LAZY, mappedBy = "terrain")
	@OrderBy(clause = "id DESC")
	@Cascade({ CascadeType.DELETE })
	public List<Comment> getComments() {
		return this.comments;
	}

	public void setComments(List<Comment> comments) {
		this.comments = comments;
	}

	@OneToMany(fetch = FetchType.LAZY, mappedBy = "terrain")
	@Cascade({ CascadeType.DELETE })
	public Set<Annotation> getAnnotations() {
		return this.annotations;
	}

	public void setAnnotations(Set<Annotation> annotations) {
		this.annotations = annotations;
	}

	@OneToMany(fetch = FetchType.LAZY, mappedBy = "terrain")
	@Cascade({ CascadeType.DELETE })
	public Set<GeneData> getGeneDatas() {
		return this.geneDatas;
	}

	public void setGeneDatas(Set<GeneData> geneDatas) {
		this.geneDatas = geneDatas;
	}

}
